package com.imooc.coupon.vo;

import com.imooc.coupon.constant.CouponCategory;
import com.imooc.coupon.constant.DistributeTarget;
import com.imooc.coupon.constant.ProductLine;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/** vo 的含义是 valueObject
 * @description:
 * @author：naxiaozi，微信：naxiaozi
 * @date: 2025/8/14
 * @Copyright：
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TemplateRequest {
    private String name;
    private String logo;
    private String desc;
    private String category;
    private Integer productLine;
    private Integer count;
    private Long userId;
    /**
    目标用户
    * */
    private Integer target;
    /**
     * 优惠券规则
     */
    private TemplateRule rule;
    /**
     * 检验对象的合法性
     */
    public boolean validate(){
        boolean stringValid = StringUtils.isNotEmpty(name)
                && StringUtils.isNotEmpty(logo)
                && StringUtils.isNotEmpty(desc);
        boolean enumValid = null != CouponCategory.of(category)
                && null != ProductLine.of(productLine)
                && null != DistributeTarget.of(productLine);
        boolean numValid = count>0 && userId>0;
        return stringValid && enumValid && numValid && rule.validate();
    }
}
